package com.woniuxy.service.impl;

import com.woniuxy.dao.UserDao;
import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

public class UserServiceImpl implements UserService {
    UserDao userDao;
    public void setUserDao(UserDao userDao) {
   this.userDao=userDao;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int addOne(User user) {
        int i=userDao.addOne(user);
        //deleteOne(41);
        /*new Thread(
                ()->{
                    deleteOne(43);
                }
        ).start();*/
        deleteOne(100);
        return i;
    }
    @Override

    public User findGoodsById(int id) {
        User user=userDao.findGoodsById(id);
        return user;
    }

    @Override
    public boolean updateOne(String username,int id) {
        boolean flag=userDao.updateOne(username,id);
        return flag;
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public boolean deleteOne(int id) {
        boolean flag=userDao.deleteOne(id);
        int j=1/0;
        return flag;
    }
}
